################################## 
############ Preamble ############ 
################################## 

# set language to English
Sys.setenv(LANG = "en")

# clean up
rm(list = ls())

# Set working directory: please set your own
#setwd("~/Dropbox/JOP third submission/JOP replication/")

# Load necessary packages
library(tidyverse)
library(readstata13)

# Import dataset
ccaa <- read.dta13("01_data/survey_ccaa_jk.dta")

# Make the plot
cabine_use_regionjk_plot <-  ccaa %>%
  filter(Removed != "fake") %>%
  filter(Model == "cabine_use") %>%
  mutate(ci_lower_90 = coef - 1.645 * stderr) %>%
  mutate(ci_upper_90 = coef + 1.645 * stderr) %>%
  ggplot(aes(x = Removed, y = coef)) +
  geom_hline(aes(yintercept = 0), linetype = 2, color = "red") + 
  coord_flip( ) + 
  geom_linerange(aes(ymin = ci_lower, ymax = ci_upper), position = position_dodge(width = 0.75), size = 0.5) + 
  geom_linerange(aes(ymin = ci_lower_90, ymax = ci_upper_90), position = position_dodge(width = 0.75), size = 1) +
  geom_point(size = 1, position = position_dodge(width = 0.75) ) + 
  theme_minimal(base_size = 9) +
  theme_bw() +
  facet_wrap(Controls~.) +
  labs(y = "Association between supporting PP and use of private voting booth", x = "Code of region ommitted")
cabine_use_regionjk_plot

ggsave("04_plots/figured9.png", plot = cabine_use_regionjk_plot, width = 20, height = 15, units = "cm")